package com.spark.laboratory.service.impl;

import com.spark.laboratory.mapper.CommentsMapper;
import com.spark.laboratory.pojo.Comments;
import com.spark.laboratory.pojo.CommentsExample;
import com.spark.laboratory.service.CommentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentsServiceImpl implements CommentsService {

    private CommentsMapper commentsMapper;

    @Autowired
    public CommentsServiceImpl(CommentsMapper commentsMapper) {
        this.commentsMapper = commentsMapper;
    }

    @Override
    public List<Comments> getCommentsIsNoDelete() {
        CommentsExample commentsExample = new CommentsExample();
        CommentsExample.Criteria criteria = commentsExample.createCriteria();
        criteria.andIsDeleteEqualTo(0);
        return commentsMapper.selectByExample(commentsExample);
    }

    @Override
    public void saveComment(Comments comments) {
        commentsMapper.insertSelective(comments);
    }
}
